﻿MLV = LibStub("AceAddon-3.0"):NewAddon("MLV", "AceConsole-3.0")

--[[ Utiliser la localisation, (true= echec silencieux)]]--
local L = LibStub("AceLocale-3.0"):GetLocale("MLV", true)

--[[Déclarer les outils Ace]]--
local AceConfig = LibStub("AceConfig-3.0")

--[[ Initalization ]]--
function MLV:OnInitialize()
    MLV:Print(L["Initialize"])--message informatif
    self.db = LibStub("AceDB-3.0"):New("MLV_DB")
    AceConfig:RegisterOptionsTable("MLV", MLV.OptionsSlash, {"MLV", "MasterLootovore"})
    --
    
    
    
end

-- declare defaults to be used in the DB
local defaults = {
  profile = {
    setting = true,
  }
}

--[[OPTIONS]]--
MLV.OptionsSlash = {
    type = "group",
    args = {
        enable = {
            name = "Activer/Désactiver MLV",
            desc = "Active/Désactive MLV",
            type = "toggle",
            set = function(info,val) MLV.enabled = val end,
            get = function(info) return MLV.enabled end
        },
        moreoptions={
            name = "More Options",
            type = "group",
            args={
            -- more options go here
            }
        }
    }
}
--[[ Activation ]]-- Called when the addon is enabled
function MLV:OnEnable()
	MLV:Print(L["Enable"])--message informatif
end

--[[Desactivation]]--Called when the addon is disabled
function MLV:OnDisable()
	MLV:Print(L["Disable"])--message informatif
end

function MLV:ChatCommand(input)
    if not input or input:trim() == "" then
        LibStub("AceConfigDialog-3.0"):Open("myOptionsTable")
    else
        LibStub("AceConfigCmd-3.0").HandleCommand(MLV, "MLV", "myOptionsTable", input)
    end
	-- Process the slash command ('input' contains whatever follows the slash command)
end



















--Register LDB Stuff
	self.ldb = LibStub("LibDataBroker-1.1"):NewDataObject("MLV", {
		type = "launcher",
		label = "MLV",
		text = "MLV",
		--icon = "Interface\\Icons\\Ability_Repair",
		OnClick = function(frame, msg)
			if msg == "RightButton" then
				if LibStub("AceConfigDialog-3.0").OpenFrames["MLV"] then
					LibStub("AceConfigDialog-3.0"):Close("MLV")
				else
					LibStub("AceConfigDialog-3.0"):Open("MLV")
				end
			else
				local error, msg = pcall(AddonParent.initBrowser)
				if not error then
					module:Print(L["Cannot Open Browser. Reason: %s"], msg)
				end
			end
		end,
		OnTooltipShow = module.OnTooltip,
		hasAce3Options = "Guild Craft",	--Application name

	})
	if LDBI then
		self.ldbiName = "MLV_DBI"
		LDBI:Register(self.ldbiName, self.ldb, self.db.char)

	end
	self:Debug("LDB Module Loaded")
end











